<?php

namespace app\backend\controller;


use app\backend\service\ZhVipIntroduceService;

class ZhVipIntroduce extends Admin
{
    /*首页数据列表*/
    function index()
    {
        if (!$this->request->isAjax()) {
            $res = ZhVipIntroduceService::indexList([], 100, 1);
            $this->view->assign('level_rows', $res['rows']);
            return view('index');
        } else {
            $limit  = $this->request->post('limit', 20, 'intval');
            $offset = $this->request->post('offset', 0, 'intval');
            $page   = floor($offset / $limit) + 1;
            $where                        = [];
            $where['title']              = $this->request->param('title', '', 'serach_in');
            $res = ZhVipIntroduceService::indexList([],  $limit, $page);
            return json($res);
        }
    }

    public function update(){
        if (!$this->request->isPost()) {
            $id = $this->request->get('id', '', 'serach_in');
            $this->view->assign('info', checkData(\app\backend\model\ZhVipIntroduce::find($id)));
            return view('update');
        } else {
            $postField = 'id,text,id,videos,p_id';
            $data      = $this->request->only(explode(',', $postField), 'post', null);
            $res = \app\backend\model\ZhVipIntroduce::update($data);
            return json(['status' => '00', 'msg' => '修改成功']);
        }
    }
}